#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 2e5 + 10;
int a[N], t[N], n;
vector<int> X;

int lowbit(int x) { return x & -x; }

int bin(int x) {
	return lower_bound(X.begin(), X.end(), x) - X.begin() + 1;
}

void update(int k, ll x) {
	for (int i = k; i <= X.size(); i+=lowbit(i)) t[i] += x;
}

ll getsum(int k) {
	ll res = 0;
	for (int i = k; i > 0; i -= lowbit(i)) res += t[i];
	return res;
}

void solve() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		X.push_back(a[i]);
	}
	sort(X.begin(), X.end());
	X.erase(unique(X.begin(), X.end()), X.end());
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		ans += getsum(X.size()) - getsum(bin(a[i]));
		update(bin(a[i]), 1);
	}
	cout << ans << '\n';
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	solve();
	return 0;
}